class Player
	def play_turn(warrior)
		if warrior.health < 5
			if !warrior.feel(:left).enemy? && !warrior.feel(:right).enemy? && !warrior.feel(:forward).enemy? && !warrior.feel(:backward).enemy?
				warrior.rest!
			elsif warrior.feel(:forward).enemy?
				warrior.bind!
			else
				warrior.rest!
			end
		else
			# add your code here
			captive = false
			warrior.listen.each{|item|
				if item.to_s() == "Captive"
					captive = true
					direction = warrior.direction_of(item)
					puts warrior.look
					if warrior.feel(direction).empty? && (warrior.look[0].to_s() != "Sludge" && warrior.look[1].to_s() != "Sludge" && warrior.look[2].to_s != "Wall")
						warrior.walk!(direction)
					elsif warrior.feel(direction).captive? && warrior.distance_of(item) == 1
						warrior.rescue!(direction)
					elsif warrior.feel(:left).enemy?
						warrior.bind!(:left)
					elsif warrior.feel(:right).enemy?
						warrior.bind!(:right)
					elsif warrior.feel(:forward).enemy?
						warrior.bind!(:forward)
					elsif warrior.look[0].to_s() == "nothing" && warrior.look[1].to_s() == "nothing"
						warrior.walk!
					elsif warrior.feel.empty? && warrior.feel(:right).empty?
						warrior.walk!(:forward)
					elsif warrior.look(direction)
						warrior.detonate!
					end
					break
				end
			}
			if(!captive)
				if warrior.feel(warrior.direction_of_stairs).enemy?
					warrior.attack!(warrior.direction_of_stairs)
				else
					warrior.walk!(warrior.direction_of_stairs)
				end
			end
		end
	  end
 end
